USE Clinic
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE up_NursesSelect
	
AS
BEGIN
	SET NOCOUNT ON;
SELECT *
FROM 
	[Nurses]
END
GO

CREATE PROCEDURE up_NursesUpdate
	@UserId uniqueidentifier
	, @NurseID int
	, @FirstName nvarchar(30)
	, @MiddleName nvarchar(30)
	, @LastName nvarchar(30)
	, @EGN nvarchar(20)
	, @Address nvarchar(100) 
	, @Phone nvarchar(20)
	, @Email nvarchar(250)
AS 
BEGIN 
	SET NOCOUNT ON;
	
	UPDATE [Nurses]
	SET 
		[UserId] = @UserId
		, [FirstName] = @FirstName
		, [MiddleName] = @MiddleName
		, [LastName] = @LastName
		, [EGN] = @EGN
		, [Address] = @Address
		, [Phone] = @Phone
		, [Email] = @Email
	WHERE 
		[NurseID] = @NurseID
END
GO

CREATE PROCEDURE up_NursesDelete
	@NurseID int
AS 
BEGIN
	SET NOCOUNT ON;
	DELETE 
	FROM 
		[Nurses] 
	WHERE 
		[NurseID] = @NurseID
END
GO
	
CREATE PROCEDURE up_NursesInsert
	@UserId uniqueidentifier
	, @NurseID int
	, @FirstName nvarchar(30)
	, @MiddleName nvarchar(30)
	, @LastName nvarchar(30)
	, @EGN nvarchar(20)
	, @Address nvarchar(100) 
	, @Phone nvarchar(20)
	, @Email nvarchar(250)
AS
BEGIN
	SET NOCOUNT ON;
	INSERT INTO [Nurses]
	(
		[UserId]
		, [FirstName]
		, [MiddleName]
		, [LastName]
		, [EGN]
		, [Address]
		, [Phone]
		, [Email]
		) 
		VALUES 
		(
			@UserId
			, @FirstName
			, @MiddleName
			, @LastName
			, @EGN
			, @Address
			, @Phone
			, @Email
		)		
END
GO

CREATE PROCEDURE up_NursesSelectById
	@NurseID int
AS
BEGIN
	SET NOCOUNT ON;
	SELECT TOP 1 *
	FROM 
		Nurses
	WHERE (NurseID = @NurseID)
END
GO

CREATE PROCEDURE up_NursesGetByUserId 
	@UserId uniqueidentifier
AS
BEGIN
	SET NOCOUNT ON;
	SELECT TOP 1 * 
	FROM 
		Nurses
	WHERE 
		@UserId = [UserId]
END
GO
